class Time:
    def __init__(self,hour,minute):
        self.h=hour
        self.m=minute

def isOverTime(t1,t2,t3):
    '''
    超时条件：t3<t2，需要设定t2-t1<2 and t2-t1<2小时？
    '''
    t2_t1=abs((t2.h-t1.h+24)%24)*60+(t2.m-t1.m)
    t3_t1=abs((t3.h-t1.h+24)%24)*60+(t3.m-t1.m)
    if t2_t1>120 or t3_t1>120:
        print("YES")
        return
    if t2.h==t3.h:
        if t3.m<=t2.m:
            print("NO")
        else:
            print("YES")
    elif t2.h>t3.h: #需要处理t2(23,1),t3(22,58)
        print("NO")
    elif t2.h<t3.h: #t2(0,1),t3(23,58)是特殊情况,t2(22,1),t3(23,58)
        if t2.h==0 and t3.h==23:
            print("NO")
        else:
            print("YES")
    
if __name__=="__main__":
    t=3
    t1=Time(18,0)
    t2=Time(19,5)
    t3=Time(19,5)
    t4=Time(23,3)
    t5=Time(0,21)
    t6=Time(0,23)
    t7=Time(23,5)
    t8=Time(0,5)
    t9=Time(23,58)
    isOverTime(t1,t2,t3)
    isOverTime(t4,t5,t6)
    isOverTime(t7,t8,t9)
    t7=Time(23,5)
    t8=Time(0,5)
    t9=Time(0,4)
    isOverTime(t7,t8,t9)



